import request from "@/utils/request"

// 获取
export async function getGoodsList(params){
    let res = await request({
        url:"/categories",
        method:"get",
        params
    })
    return res
}

// 添加分类
export async function addCategories(params){
    let res = await request({
        url:"/categories",
        method:"post",
        data:params
    })
    return res
}
// 根据id查询分类
export async function findCategories(params){
    let res = await request({
        url:`/categories/${params.id}`,
        method:"get",
        // data:params
    })
    return res
}


// 编辑提交分类
export async function editCategories(id,cat_name){
    let res = await request({
        url:`/categories/${id}`,
        method:"put",
        data:cat_name
    })
    return res
}

// 删除分类
export async function delCategories(id){
    let res = await request({
        url:`/categories/${id}`,
        method:"delete",
        // data:cat_name
    })
    return res
}

// 分类参数列表
export async function getCategoriesAttributes(params){
    let res = await request({
        url:`/categories/${params.id}/attributes`,
        method:"get",
        params:params.sel
    })
    return res
}

// 修改 参数 或者静态属性  多个参数传递的时候 用data 就行
export async function editCategoriesAttributes(id,params){
    let res = await request({
        url:`/categories/${id}/attributes`,
        method:"post",
        data:params
    })
    return res
}


// 删除 参数
export async function delCategoriesAttributes(params){
    let res = await request({
        url:`/categories/${params.id}/attributes/${params.attrid}`,
        method:"delete",
    })
    return res
}

// 根据id查询 参数
export async function getCategoriesAttributesById(params){
    let res = await request({
        url:`/categories/${params.id}/attributes/${params.attrid}`,
        method:"get",
        data:params.attr_sel
    })
    return res
}

// 编辑 参数  byids
export async function editCategoriesAttributesById(params){
    let res = await request({
        url:`/categories/${params.id}/attributes/${params.attrId}`,
        method:"put",
        data:params.info
    })
    return res
}